package mini.expr;
import java.util.List;
import java.util.LinkedList;

import mini.Env;
import mini.util.MiniUtil;


public class Ident extends Expr {

    private String name;

    public Ident(String s) {
        name = s;
    }

    public Element eval(List<Env> listOfEnvs, LinkedList var) {
    	
    	// Could be either from the nametable or the functiontable
    	Element nameElement = MiniUtil.lookupSymbol(listOfEnvs, name);
    	if( nameElement != null ) {
    		return nameElement;
    	}
    
    	// Hopefully it's in the functiontable
        return new Element(MiniUtil.lookupFunction(listOfEnvs, name));
    }
    
    public String toString() {
    	return "[Ident name=" + name + "]";
    }
}